// import axios from './contents/axios.js'
(
    function () {
        let mycontent = document.querySelector(".mytext>.mycontent");
        // 为给定 ID 的 user 创建请求
        axios.get('/api/issuefalse',
        ).then(function (res) {
            console.log(res);
            res.data.forEach(item => {
                console.log(item);
                let mycontent = document.querySelector(".mycontent");
                let html = [];
                let str = '';
                let html1 = [];
                let img1 = [];
                let img2 = '';
                str = item.content;
                let imgreg = /src=[\'\"]?([^\'\"]*)[\'\"]?/gi;
                let imgArr = item.content.match(imgreg);
                console.log(imgArr);
                imgArr.forEach((item) => {
                    img1.push(JSON.parse(item.split('=')[1]));
                });
                // console.log(img1);
                img1.forEach(item => {
                    // console.log(item);
                    // let img = document.createElement("img");
                    // img.src = item;
                    // console.log(img);

                    img2 += `<img src = '${item}'>`
                    // console.log(img2);
                })


                html.push(str.split("</p>")[0].split('<p>')[1]);
                // console.log(html);
                html.forEach(item => {
                    html1.push(item.split("<img")[0]);
                })
                mycontent.innerHTML += `
                            <div class="mycontent-diaft">
                                <div class="my-top">
                                    <div class="diaft-left">
                                    <img src="./images/1.jpg" alt="">
                                </div>
                                <div class="diaft-rigth">
                                    <div class="diaft-top">${item.title}</div>
                                    <div class="diaft-center">新帖子草稿</div>
                                    <div class="diaft-bottom">${html1.join('')}</div>
                                </div>
                            </div>
                            <div class="my-bottom">
                                ${img2}
                            </div>
                            <span>最后保存时间:&nbsp;&nbsp;&nbsp;${item.updatetimes}</span>
                `
            });
            // html1 = html1.join('');
            // console.log(html1);
        }).catch(function (error) {
            console.log(error);
        });
    }
)();